<?php

namespace App\Console\Commands;

use App\Common\Comp\VideoTranscodingComp;
use App\Common\RabbitMQ\AbstractConsumer;
use App\Common\RabbitMQ\AbstractPublisher;
use App\Common\RabbitMQ\McnTaskCompleteConsumer;
use App\Common\RabbitMQ\VideoTranscodeCheckPublisher;
use App\Common\RabbitMQ\VideoTranscodingConsumerTwo;
use App\Model\Mcn\McnMessage;
use App\Model\Mcn\McnTask;
use App\Service\Mcn\TaskService;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

class McnLaterOverdue extends Command
{


    protected $signature = 'McnLaterOverdue';#你的方法名字

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '处理MCN已过期的任务和消息公告';

    /**
     * Create a new command instance.
     *
     * @return void
     */

    public function __construct()
    {
        parent::__construct();
    }


    /**
     *
     * @return void
     * @throws \AMQPQueueException
     */
    public function handle()
    {
        $this->overdue();
    }

    public function overdue()
    {
        $time = time();
        $message = McnMessage::where('send_time','<=',$time)->update([
            'send_status' => McnMessage::ALREADY_SEND,
        ]);
        $task = McnTask::where('end_time','<=',$time)->update([
            'status' => McnTask::STATUS_UP,
        ]);
        Log::info('机构任务过期关闭结果{'.$task.'}');
        Log::info('机构消息公告过期关闭结果{'.$message.'}');
    }
}
